import java.util.LinkedList;
import java.util.ListIterator;

public class Test {
    public static void main(String[] args) {
        LinkedList<String> linkedList = new LinkedList<>();


        linkedList.add("hello");
        linkedList.add("ok");
        linkedList.add("good");
        //利用迭代器来遍历linkedList
        ListIterator<String> it = linkedList.listIterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
        System.out.println("=========");
        //反向打印
        ListIterator<String> it2 = linkedList.listIterator(linkedList.size());
        while (it2.hasPrevious()) {
            System.out.println(it2.previous());
        }
    }

}
